package list_Node;
//82. 删除排序链表中的重复元素 II(一个不留)


public class Num82_deleteDuplicates {
    public ListNode deleteDuplicates(ListNode head) {

        if (head == null){
            return null;
        }
        ListNode dummy = new ListNode(0,head);
        ListNode prev = dummy;
        ListNode cur = null;
        while (prev!=null && prev.next!=null){
            cur = prev.next;
            while (cur.next != null && prev.next.val == cur.next.val){
                cur = cur.next;
            }
            if (prev.next == cur){
                prev = prev.next;
            }else {
                prev.next = cur.next;
            }

        }
        return dummy.next;


    }







}
